package dyyx.demo;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.client.RestTemplate;

public class RestTemplateDemo {

	public static void main(final String[] args) {
		
		RestTemplate restTemplate = new RestTemplate();
		String url = "http://codefun007.xyz/";
		String response = restTemplate.getForObject(url,String.class);
		System.out.println(response);
		
		System.out.println("\n\n");

		
		// springboothello
		// https://gitee.com/dyyx/springboothello
		url = "http://127.0.0.1:8090/demohello";
		response = restTemplate.getForObject(url,String.class);
		System.out.println(response);
		
		url = "http://127.0.0.1:8090/user/getById/{id}";		
		Map<String,Object> params = new HashMap<>();
		params.put("id", 1);
		Map map = restTemplate.getForObject(url,Map.class,params);
		System.out.println(map);
		
		
		url = "http://127.0.0.1:8090/user/echo";
		params = new HashMap<>();
	    params.put("id", 1);
	    params.put("name", "tiger");

		map = restTemplate.postForObject(url, params, Map.class);
		System.out.println(map);

		


		
	}



}
